﻿@{
    ViewBag.Title = "创建文章";
    Layout = "~/Views/Shared/_ManageLayoutPage.cshtml";
    var categories = ViewBag.Categories as IList<TBlog.Web.Models.Category>;
}
<blockquote class="layui-elem-quote blog-manage-breadcrumb">
    <span class="layui-breadcrumb">
        <a href="@Url.Action("GetListArticle", "Article")">文章管理</a>
        <a><cite>创建文章</cite></a>
    </span>
</blockquote>
@using (Html.BeginForm("Create", "Article", FormMethod.Post, new { @class = "layui-form" }))
{@Html.AntiForgeryToken()
    <form class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">标题</label>
            <div class="layui-input-block">
                <input type="text" name="Title" lay-verify="required" autocomplete="off" placeholder="请输入标题" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">作者</label>
            <div class="layui-input-block">
                <input type="text" name="Author" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">分类</label>
            <div class="layui-input-block">
                <select name="categoryID">
                    @if (categories != null && categories.Count > 0)
                    {
                        foreach (var item in categories)
                        {
                        <option value="@item.ID">@item.CategoryName</option>
                        }
                    }
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">标签</label>
            <div class="layui-input-block">
                <input type="text" name="Tags" lay-verify="required" placeholder="请输入标签,可以用英文逗号隔开" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <select name="State">
                    <option value="0">全部</option>
                    <option value="1">正常</option>
                    <option value="2">草稿</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">正文</label>
            <div class="layui-input-block">
                <textarea name="Content" id="Content" class="layui-textarea layui-hide"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="sub">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                <a name="test" class="layui-btn">测试</a>
            </div>
        </div>
    </form>
}
@section scripts{
    <script>
        layui.use(['jquery', 'layer', 'form', 'element', 'laydate', 'layedit'], function () {
            var $ = layui.jquery, element = layui.element, form = layui.form(), laydate = layui.laydate, layedit = layui.layedit;
            var editIndex = layedit.build('Content');
            form.verify({
                title: function (value) {
                    if (value.length > 5) {
                        return '标题至少5个字符'
                    }
                }
            })
        
            var item = $('.layui-nav > .layui-nav-item');
            item.removeClass('layui-this').eq(2).addClass('layui-this');
            //form.on('submit(sub)', function (data) {
            //    layer.alert(JSON.stringify(data.field), {
            //        title: '最终的提交信息',
            //    })
            //    //  layui.alert(layui.getContent(editIndex));

            //    // return false;
            //})
        })
    </script>
}